<?php
namespace app\examine\controller;

use think\Controller;
use tp5_lib\examine\utility\DemoExamine;

class IndexController extends Controller
{
    protected function getExamine()
    {
        return new DemoExamine;
    }
    public function index()
    {
        $examine = $this->getExamine();
        if(!$examine->check()){
            return $this->fetch("/fault",[
                "messages" => $examine->onFaultAppear(),
            ]);
        }
        return $this->fetch("/fine");
    }
    public function repair()
    {
        $examine = $this->getExamine();
        if($examine->check()){
            $this->error("无需修复");
        }
        if($examine->manual){
            $this->error("需要手动修复");
        }
        if(!$examine->repair()){
            $this->error("修复失败");
        }
        $this->success("修复成功");
    }
    public function recover()
    {
        session("demo_examine_repaired",null);
        $this->success("恢复成功");
    }
}
